<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/public/header.jsp"%>
<%
    String callback = request.getParameter("callback");
    String parent_id = request.getParameter("parent_id") == null ? "" : request.getParameter("parent_id");
    String parent_name = request.getParameter("parent_name") == null ? "" : request.getParameter("parent_name");
    String parent_tree_code = request.getParameter("parent_tree_code") == null ? "" : request.getParameter("parent_tree_code");
    String type = request.getParameter("parent_type") == null ? "" : request.getParameter("parent_type");
    String id = request.getParameter("id") == null ? "" : request.getParameter("id");
    boolean isAdd = "".equals(id);
%>

<html>
	<head>
		<title><%=isAdd?"新建系统类别 ":"编辑系统类别" %></title>
		<style>
			.td1{
				padding-top:10px;
				padding-bottom:5px;
				font-size: 12px;
				background-color: #c0ebd7;
				width:20%;
			}
			.td2{
				padding:5px;
				width:30%;
			}
			.tdg{
			padding-top:10px;
			padding-bottom:5px;
			font-size: 12px;
			background-color: #c0ebd7;
			width:20%;
		}
		.tdb{
			padding:5px;
			width:30%;
		}
		</style>
	</head>
	<script type="text/javascript">	
		$(function(){
			$("#name").keypress(function(e) { 
     	  		if(e.which == 13) { 
     	  			doSubmit();
       			} 
   			}); 
			<%=isAdd?"":"$('#fm').form('load','"+contextPath+"/springMVC/group/getSystemTypeById?id="+id+"');"%>
		});
		
		function doSubmit(obj){
			$("#fm").form('submit',{
				url:"<%=contextPath %>/springMVC/group/<%=isAdd ? "addSystemType?parent_id="+parent_id+"&parent_name="+parent_name+"&parent_tree_code="+parent_tree_code+"&type="+type : "updateSystemType?id=" + id%>",
				onSubmit:function(){
					var isValid = $(this).form('validate');
					if(isValid){
						$(obj).hide();
					}
					return isValid;
				},
				success:function(rtJson){
					rtJson = eval('(' + rtJson + ')'); 
					if (rtJson.rtState == '0'){
						eval('window.opener.<%=callback%>();');
						window.close();
					}else{
						$(obj).show();
						warningInfo(rtJson.rtMsrg);
					}
				}
			});
		}
	</script>
	<body>
		<form id="fm" method="post">
		<div style="width:90%;padding-left:50px;margin-top:50px">
			<table  style="border-collapse: collapse;" width="100%" border="1px" bordercolor="#0eb83a">
				<tr>
				<td align="right"  class="td1" nowrap>
						排序号：
					</td>
					<td  class="td2" nowrap>
						<input id="sort" name="sort" class="easyui-numberbox"  data-options="required:true"/> 
					</td>
					</tr>
				<tr>
					<td align="right"  nowrap class="td1">
						名称：
					</td>
					<td class="td2" nowrap >
						<input id="name" name="name"  class="easyui-validatebox" data-options="required:true"/>
					</td>
				</tr>
				<tr>
					<td align="right" nowrap class="td1">
					</td>
					<td  nowrap colspan="5">
						<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:false" onclick="doSubmit(this);">保存</a>
						<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:false" onclick="javascript:window.close();">关闭</a>
					</td>
				</tr>
				
 			</table>
		</div>
		</form>
	</body>
</html>
